![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
tonal-pitch
Advanced tools
tonal-pitch
is a low level module to encode and manipulate music pitch and intervals.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-pitch
Pitch
Create a pitch
Boolean
Test if an object is a pitch
Encode a pitch
Array
Decode a pitch
String
Get pitch type
Boolean
Test if is a pitch note (with or without octave)
Boolean
Test if is an interval
Boolean
Test if is a pitch class (a pitch note without octave)
Integer
Get direction of a pitch (even for notes)
Integer
Get encoded fifths from pitch.
Integer
Get encoded octaves from pitch.
Integer
Get height of a pitch.
Integer
Get chroma of a pitch. The chroma is a number between 0 and 11 to represent the position of a pitch inside an octave. Is the numeric equivlent of a pitch class.
Pitch
Parse a note
Pitch
Parse an interval
Pitch
Parse a note or an interval
Pitch
Ensure the given object is a note pitch. If is a string, it will be parsed. If not a note pitch or valid note string, it returns null.
Pitch
Ensure the given object is a interval pitch. If is a string, it will be parsed. If not a interval pitch or valid interval string, it returns null.
Pitch
Ensure the given object is a pitch. If is a string, it will be parsed. If not a pitch or valid pitch string, it returns null.
String
Convert a note pitch to string representation
String
Convert a interval pitch to string representation
String
Convert a pitch to string representation (either notes or intervals)
function
Decorate a function to work internally with note pitches, even if the parameters are provided as strings. Also it converts back the result to string if a note pitch is returned.
function
Decorate a function to work internally with interval pitches, even if the parameters are provided as strings. Also it converts back the result to string if a interval pitch is returned.
function
Decorate a function to work internally with pitches, even if the parameters are provided as strings. Also it converts back the result to string if a pitch is returned.
Pitch
Create a pitch
Param | Type | Description |
---|---|---|
fifths | Integer | the number of fifths from C or from P1 |
focts | Integer | the number of encoded octaves |
dir | Integer | (Optional) Only required for intervals. Can be 1 or -1 |
Boolean
Test if an object is a pitch
Param | Type |
---|---|
p | Pitch |
Encode a pitch
Param | Type | Description |
---|---|---|
step | Integer | |
alt | Integer | |
oct | Integer | |
dir | Integer | (Optional) |
Array
Decode a pitch
Returns: Array
- An array with [step, alt, oct]
Param | Type | Description |
---|---|---|
the | Pitch | pitch |
String
Get pitch type
Returns: String
- 'ivl' or 'note' or null if not a pitch
Param | Type |
---|---|
p | Pitch |
Boolean
Test if is a pitch note (with or without octave)
Param | Type |
---|---|
p | Pitch |
Boolean
Test if is an interval
Param | Type |
---|---|
p | Pitch |
Boolean
Test if is a pitch class (a pitch note without octave)
Param | Type |
---|---|
p | Pitch |
Integer
Get direction of a pitch (even for notes)
Returns: Integer
- 1 or -1
Param | Type |
---|---|
p | Pitch |
Integer
Get encoded fifths from pitch.
Param | Type |
---|---|
p | Pitch |
Integer
Get encoded octaves from pitch.
Param | Type |
---|---|
p | Pitch |
Integer
Get height of a pitch.
Param | Type |
---|---|
p | Pitch |
Integer
Get chroma of a pitch. The chroma is a number between 0 and 11 to represent the position of a pitch inside an octave. Is the numeric equivlent of a pitch class.
Param | Type |
---|---|
p | Pitch |
Pitch
Parse a note
Returns: Pitch
- the pitch or null if not valid note string
Param | Type |
---|---|
str | String |
Pitch
Parse an interval
Returns: Pitch
- the pitch or null if not valid interval string
Param | Type |
---|---|
str | String |
Pitch
Parse a note or an interval
Returns: Pitch
- the pitch or null if not valid pitch string
Param | Type |
---|---|
str | String |
Pitch
Ensure the given object is a note pitch. If is a string, it will be parsed. If not a note pitch or valid note string, it returns null.
Param | Type |
---|---|
p | Pitch | String |
Pitch
Ensure the given object is a interval pitch. If is a string, it will be parsed. If not a interval pitch or valid interval string, it returns null.
Param | Type |
---|---|
p | Pitch | String |
Pitch
Ensure the given object is a pitch. If is a string, it will be parsed. If not a pitch or valid pitch string, it returns null.
Param | Type |
---|---|
p | Pitch | String |
String
Convert a note pitch to string representation
Param | Type |
---|---|
p | Pitch |
String
Convert a interval pitch to string representation
Param | Type |
---|---|
p | Pitch |
String
Convert a pitch to string representation (either notes or intervals)
Param | Type |
---|---|
p | Pitch |
function
Decorate a function to work internally with note pitches, even if the parameters are provided as strings. Also it converts back the result to string if a note pitch is returned.
Returns: function
- the decorated function
Param | Type |
---|---|
fn | function |
function
Decorate a function to work internally with interval pitches, even if the parameters are provided as strings. Also it converts back the result to string if a interval pitch is returned.
Returns: function
- the decorated function
Param | Type |
---|---|
fn | function |
function
Decorate a function to work internally with pitches, even if the parameters are provided as strings. Also it converts back the result to string if a pitch is returned.
Returns: function
- the decorated function
Param | Type |
---|---|
fn | function |
FAQs
Music pitch utilities
The npm package tonal-pitch receives a total of 12 weekly downloads. As such, tonal-pitch popularity was classified as not popular.
We found that tonal-pitch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.